package connect4client.commands;

import messages.*;

/**
 * The PluginOperationSuccessful command.
 * 
 * This command will handle PluginOperationSuccessful messages.
 */
public class PluginOperationSuccessfulCommand extends Command {

	public PluginOperationSuccessfulCommand(PluginOperationSuccessfulMessage message){
		super(message);
	}
	
	@Override
	public void execute() {		
		Message originalMessage = ((PluginOperationSuccessfulMessage) message).getOriginalMessage();
		
		if (originalMessage instanceof StartPluginMessage) {
			StartPluginMessage startMessage = (StartPluginMessage) originalMessage;
			guiMediator.pluginStartupSuccessful(startMessage.getSenderLogin(), startMessage.getPluginName());
		} else if (originalMessage instanceof StopPluginMessage) {
			StopPluginMessage stopMessage = (StopPluginMessage) originalMessage;
			guiMediator.pluginShutdownSuccessful(stopMessage.getSenderLogin(), stopMessage.getPluginName());
		}
	}
}
